package com.wzy.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;

/**
 * 流程定义的部署
 * 注意:级联删除
 * 如果要求强制删除,可以使用repositoryService.deleteDeployment("1",true) ,true代表级联删除
 */
public class ActivitiDeployment {
    //流程定义部署
    public static void main(String[] args) {
        //1.创建processEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        //2.得到RepositoryService实例
        RepositoryService repositoryService = processEngine.getRepositoryService();
        //3.进行部署
        Deployment deploy = repositoryService.createDeployment()
                .addClasspathResource("diagram/holiday2.bpmn")//读取图文文件
                .addClasspathResource("diagram/holiday2.png")
                .name("请假申请单流程")
                .deploy();
        //4.输出一些部署信息
        System.out.println(deploy.getName());
        System.out.println(deploy.getId());
    }
}
